package com.xckj.cycling.dialog

import android.content.Context
import android.view.Gravity
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatDialog
import com.xckj.cycling.R

open class BaseDialog(context: Context) : AppCompatDialog(context, R.style.Dialog) {
    override fun onContentChanged() {
        super.onContentChanged()
        setFullScreen()
    }

    open fun setFullScreen() {
        window?.apply {
            setLayout(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)
            setBackgroundDrawable(null)
            decorView.background = null
            setGravity(Gravity.BOTTOM)
            decorView.apply {
                layoutParams = FrameLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    Gravity.BOTTOM
                )
            }
        }
    }
}